package org.opens.guava.utilites.eventBus.monitor;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FileChangeListener {

    private final static Logger LOGGER = LoggerFactory.getLogger(FileChangeListener.class);


    /**  被final修饰的字段必须初始化 */
    private final EventBus eventBus;

    public FileChangeListener(EventBus eventBus) {
        this.eventBus = eventBus;
        eventBus.register(this);
    }

    @Subscribe
    public void onChange(FileChangeEvent event) {
        LOGGER.info("{}-{}", event.getPath(), event.getKind());
    }

}
